import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import query from '@dfeidao/atom-nodejs/db/query';
import { systemid,productid} from '../../atom/config';
import complex_query from '@dfeidao/atom-nodejs/db/complex-query';
import get_field from '@dfeidao/atom-nodejs/data/get-field';

interface Message {
    filter:{
        startime:string,
        endtime:string
        work_order_status:string
    }
}


export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders){
    const ofo=[];
    const query = complex_query(action_id,session_id,systemid);
    for (let i = 0; i <6; i++) {
        const res = await query
        .add_fun('work_order', 'work_order_status', 'work_order_status', 'count')
         // 大于3
         .where_gt('work_order', 'create_time', message.filter.startime)
      //等于
         .where_eq('work_order', 'work_order_status', message.filter.work_order_status[i])
            // 小于
        .where_lt('work_order', 'create_time',message.filter.endtime)
        .exec();
    const as= await get_field(res,'work_order_status');
    ofo.push(as);
    }
    return {ofo};
}
